<template>
  <div class="container">
    <div>我是父组件 {{money}}</div>
    <button @click="money = 1000">发钱</button>
    <hr>
    <Son></Son>
  </div>
</template>

<script>
import Son from './components/Son6.vue'
import {ref, provide} from 'vue'
export default {
  name: 'App',
  components: {
    Son
  },
  setup () {
    const money = ref (100)
    const changeMoney = (saleMoney) => {
      money.value = money.value - saleMoney 
    }

    // 提供给后代
    provide ('money', money)

    provide ('changeMoney', changeMoney)

    return {money}
  }
}
</script>

<style>

</style>